home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-19 / iritsm3s.zip / INTR_LIB.H < prev    next >
C/C++ Source or Header  |  1992-01-26  |  18KB  |  444 lines

  1. /******************************************************************************
  2. * MSDOS Interaction library main header file.                      *
  3. *                                          *
  4. *                    Written by Gershon Elber,  Oct. 1990  *
  5. *******************************************************************************
  6. * History:                                      *
  7. *  3 Oct 90 - Version 1.0 by Gershon Elber.                      *
  8. ******************************************************************************/
  9.  
  10. #ifndef INTR_LIB_H
  11. #define INTR_LIB_H
  12.  
  13. #ifndef TRUE
  14. #define TRUE 1
  15. #define FALSE 0
  16. #endif
  17.  
  18. #ifdef NO_VOID_PTR
  19. #define VoidPtr        char *
  20. #else
  21. #define VoidPtr        void *
  22. #endif /* NO_VOID_PTR */
  23.  
  24. #define IntrBType int                              /* Boolean type. */
  25. #define IntrRType float                     /* Floating point type. */
  26.  
  27. #define INTR_WNDW_PULL_DOWN   -10000 /* WindowID signals pull down position. */
  28. #define INTR_WNDW_PLACE_CENTER    0    /* WindowID signals screen position. */
  29. #define INTR_WNDW_PLACE_LEFT    -1
  30. #define INTR_WNDW_PLACE_RIGHT    -2
  31.  
  32. typedef enum {
  33.     INTR_EVNT_NONE = 0,
  34.     INTR_EVNT_SELECT,
  35.     INTR_EVNT_ABORT,
  36.     INTR_EVNT_MIDDLE_BUTTON,
  37.     INTR_EVNT_MOVE,
  38.     INTR_EVNT_KEY,
  39.     INTR_EVNT_REFRESH
  40. } IntrEventType;
  41.  
  42. typedef enum {                    /* Window type supported by library. */
  43.     INTR_WNDW_NONE = 0,
  44.     INTR_WNDW_GRAPH = 1,
  45.     INTR_WNDW_TEXT = 2,
  46.     INTR_WNDW_ROOT = 4
  47. } IntrWindowType;
  48.  
  49. typedef enum {                /* Scroll bar type supported by library. */
  50.     INTR_SCRLBAR_NONE = 0,
  51.     INTR_SCRLBAR_LEFT,
  52.     INTR_SCRLBAR_RIGHT,
  53.     INTR_SCRLBAR_TOP,
  54.     INTR_SCRLBAR_BOTTOM
  55. } IntrScrlBarType;
  56.  
  57. typedef enum {                      /* Color supported by library. */
  58.     INTR_COLOR_WHITE = 0,
  59.     INTR_COLOR_BLACK,
  60.     INTR_COLOR_RED,
  61.     INTR_COLOR_GREEN,
  62.     INTR_COLOR_BLUE,
  63.     INTR_COLOR_YELLOW,
  64.     INTR_COLOR_CYAN,
  65.     INTR_COLOR_MAGENTA,
  66.  
  67.     INTR_NUM_COLORS,
  68.  
  69.     INTR_COLOR_NONE
  70. } IntrColorType;
  71.  
  72. typedef enum {                /* Four intensity levels for each color. */
  73.     INTR_INTENSITY_VHIGH = 0,
  74.     INTR_INTENSITY_HIGH,
  75.     INTR_INTENSITY_LOW,
  76.     INTR_INTENSITY_VLOW
  77. } IntrIntensityType;
  78.  
  79. typedef enum {                 /* Type of input devices supported. */
  80.     INTR_INPT_DEVICE_MOUSE = 1,
  81.     INTR_INPT_DEVICE_JOYSTICK = 2,
  82.     INTR_INPT_DEVICE_KEYBOARD = 4
  83. } IntrInputDeviceType;
  84.  
  85. typedef enum {                        /* Type of cursor shape. */
  86.     INTR_CURSOR_CROSS,
  87.     INTR_CURSOR_CROSS_LAST,
  88.     INTR_CURSOR_SCROSS,
  89.     INTR_CURSOR_ARROW,
  90.     INTR_CURSOR_BOX,
  91.     INTR_CURSOR_BOX_LAST,
  92.     INTR_CURSOR_CUSTOM,
  93.     INTR_CURSOR_MASK,
  94.  
  95.     INTR_CURSOR_PUSH,
  96.     INTR_CURSOR_POP
  97. } IntrCursorType;
  98.  
  99. typedef enum {
  100.     INTR_SAVE_CONV,
  101.     INTR_SAVE_EMS,
  102.     INTR_SAVE_XMS,
  103.     INTR_SAVE_DISK
  104. } IntrSaveMemType;
  105.  
  106. typedef enum {
  107.     INTR_FILL_SOLID = 1
  108. } IntrFillType;
  109.  
  110. typedef void (* IntrVoidFunc)(void);
  111. typedef void (* IntrIntFunc)(int);
  112. typedef IntrEventType (* IntrInt2PtrFunc)(int *, int *);
  113.  
  114. typedef struct {
  115.     int Xmin, Ymin, Xmax, Ymax, _Dx, _Dy;
  116. } IntrBBoxStruct;
  117.  
  118. typedef struct {
  119.     IntrRType FXmin, FYmin, FXmax, FYmax, _FDx, _FDy;
  120. } IntrFBBoxStruct;
  121.  
  122. typedef struct IntrCursorShapeStruct {
  123.     IntrCursorType CursorType;
  124.     int Width, Height;           /* Width/Height information to use if needed. */
  125.     int LastX, LastY;        /* LastX/LastY information to use if needed. */
  126.     IntrBType LastHV;          /* If TRUE Draw Horiz/Vert line to last coord. */
  127.     void (* CursorRoutine)(int, int);
  128.     IntrBType _CursorVisible;
  129. } IntrCursorShapeStruct;
  130.  
  131. typedef struct {
  132.     char *TextData;
  133.     IntrBType ReadBottomLine;      /* If bottom line is used as reading line. */
  134.     IntrColorType TextColor, BottomLineColor;
  135.     int NumOfLines;                 /* Number of lines to be saved. */
  136.     int LineLen;                      /* Maximum length of line. */
  137.     int LinesInBuffer;                          /* Number of lines active. */
  138.     int FirstDisplayed;                        /* First line displayed. */
  139.     int NumOfDisplayedLines;          /* Depends on current window size. */
  140. } _IntrWndwTextStruct;
  141.  
  142. typedef struct _IntrWindowStruct {
  143.     int WindowID;                      /* Window handle I.D.. */
  144.     int WindowFullSize;        /* TRUE if window is using screen full size. */
  145.     IntrWindowType WindowType;
  146.     char *Name, *StatusLeft, *StatusRight; /* Strings describing the window. */
  147.     IntrBType DrawHeader;         /* TRUE will show header (if Name != NULL) */
  148.     IntrBType MappedToScreen;               /* TRUE if should be visible. */
  149.     IntrBType DrawnOnScreen;          /* TRUE if was drawn, FALSE otherwise. */
  150.     int FrameWidth;           /* Window Frame width in screen space coords. */
  151.     IntrBBoxStruct BBox;    /* Window (Interior) dimensions in screen space. */
  152.     IntrBBoxStruct PushBBox;           /* One level BBox size pushing stack. */
  153.     IntrFBBoxStruct FBBox;              /* Real coordinates of window. */
  154.     IntrScrlBarType HScrlBar, VScrlBar;         /* If should have a scroll bar. */
  155.     IntrColorType HScrlBarColor, VScrlBarColor;     /* Window Scroll Bar Color. */
  156.     IntrColorType FrameColor;                  /* Window Frame Color. */
  157.     IntrColorType BackColor;            /* Window Back Ground Color. */
  158.     int ZoomFactor, PanFactorX, PanFactorY;      /* Window drawing control. */
  159.     IntrCursorShapeStruct Cursor;      /* Cursor to use while window active. */
  160.     _IntrWndwTextStruct *TextInfo;       /* If the window is to handle text. */
  161.     struct IntrPullDownMenuStruct *PDMenu;    /* At most one pull down menu. */
  162.     IntrIntFunc RefreshFunc;             /* Window refresh function. */
  163.     struct _IntrWindowStruct *Pnext;
  164. } _IntrWindowStruct;
  165.  
  166. typedef struct IntrPopUpMenuStruct {
  167.     int NumOfEntries;                 /* Number of items in menu. */
  168.     int SizeOfEntry;                        /* Size of item. */
  169.     char *Header;                       /* Of menu - name of menu. */
  170.     char **StrEntries;                         /* The entries. */
  171.     struct IntrCursorShapeStruct Cursor; /* Cursor to use while menu active. */
  172.     IntrColorType ForeColor, BackColor, FrameColor, XorColor;/* Menu colors. */
  173.     int FrameWidth, _MenuWidth, _MenuHeight;        /* Dimensions in pixels. */
  174.     int SelectedIndex;           /* Index of last item selected when poped up. */
  175. } IntrPopUpMenuStruct;
  176.  
  177. typedef struct IntrPullDownMenuStruct {
  178.     int NumOfEntries;                 /* Number of items in menu. */
  179.     int SizeOfEntry;                        /* Size of item. */
  180.     int WindowID;    /* Pull Down menus must be associated with a window. */
  181.     char **StrEntries;                         /* The entries. */
  182.     IntrColorType ForeColor, BackColor, FrameColor, XorColor;/* Menu colors. */
  183.     int FrameWidth;                    /* Dimensions in pixels. */
  184.     IntrIntFunc *ActionFuncs;     /* Function called when menu is activated. */
  185.     int DrawnEntryWidth;           /* Width of each drawn entry in the menu. */
  186.     int _ActiveIndex;              /* -1 if none active, index if active. */
  187. } IntrPullDownMenuStruct;
  188.  
  189. /******************************************************************************
  190. * Function prototypes.                                  *
  191. ******************************************************************************/
  192.  
  193. /* Initialization and closing routines. */
  194. void IntrInit(void);
  195. void IntrClose(void);
  196.  
  197. /* Generic routines: */
  198. void IntrFatalError(char *Msg);
  199. int IntrPopUpActive(void);
  200.  
  201. /* Color allocation routines. */
  202. int IntrAllocColor(IntrColorType Color, IntrIntensityType Intensity);
  203. void IntrAllow256Colors(IntrBType Allow256Colors);
  204.  
  205. /* Window manipulation routines. */
  206. int IntrWndwCreate(char *WindowName,
  207.            int FrameWidth,
  208.            IntrBBoxStruct *BBox,
  209.            IntrColorType FrameColor,
  210.            IntrColorType BackColor,
  211.            IntrCursorShapeStruct *Cursor,
  212.            IntrPullDownMenuStruct *PDMenu,
  213.            IntrIntFunc RefreshFunc);
  214. void IntrWndwSetRoot(int RootWindowID);
  215. void IntrWndwSelect(int WindowID);
  216. void IntrWndwSelectAll(IntrBType SelectAll);
  217. void IntrWndwRedrawAll(void);
  218. int IntrWndwPick(void);
  219. void IntrWndwPop(int WindowID, IntrBType DoRedraw, IntrBType DoClear);
  220. void IntrWndwPush(int WindowID, IntrBType DoRedraw);
  221. IntrBType IntrWndwIsAllVisible(int WindowID);
  222. void IntrWndwSetResizeBBox(IntrBBoxStruct *BBox);
  223. IntrBType IntrWndwMove(int WindowID, IntrBType Refresh);
  224. IntrBType IntrWndwResize(int WindowID, IntrBType Refresh);
  225. void IntrWndwFullSize(int WindowID, IntrBType Refresh);
  226. void IntrWndwHide(int WindowID, IntrBType Refresh);
  227. void IntrWndwDelete(int WindowID, IntrBType Refresh);
  228. int IntrWndwGetHeaderHeight(char *Header, int FrameWidth);
  229. IntrBBoxStruct *IntrWndwGetBBox(int WindowID);
  230. IntrFBBoxStruct *IntrWndwGetFBBox(int WindowID);
  231. IntrColorType IntrWndwGetFrameColor(int WindowID);
  232. IntrColorType IntrWndwGetBackGroundColor(int WindowID);
  233. IntrCursorShapeStruct *IntrWndwGetCursorShape(int WindowID);
  234. IntrPullDownMenuStruct *IntrWndwGetPullDownMenu(int WindowID);
  235. int IntrWndwGetZoomFactor(int WindowID);
  236. IntrIntFunc IntrWndwGetRefreshFunc(int WindowID);
  237. void IntrWndwGetPanFactors(int WindowID, int *x, int *y);
  238. void IntrWndwSetName(int WindowID, char *Name);
  239. void IntrWndwSetDrawHeader(int WindowID, IntrBType DrawHeader);
  240. void IntrWndwSetBBox(int WindowID, IntrBBoxStruct *BBox);
  241. void IntrWndwSetFBBox(int WindowID, IntrFBBoxStruct *FBBox);
  242. void IntrWndwSetFrameColor(int WindowID, IntrColorType FrameColor);
  243. void IntrWndwSetBackGroundColor(int WindowID, IntrColorType BackColor);
  244. IntrBType IntrWndwIsScrollBarEvent(int WindowID, IntrBType *IsVertical, IntrRType *Value);
  245. int IntrWndwScrollBarWidth(void);
  246. void IntrWndwUpdateScrollBar(int WindowID,
  247.                  IntrBType IsVertical,
  248.                      IntrRType RelativePosition,
  249.                              IntrRType DisplayedFraction);
  250. void IntrWndwSetScrlBar(int WindowID,
  251.             IntrBType IsVertical,
  252.             IntrScrlBarType ScrlBar,
  253.                         IntrColorType ScrlBarColor);
  254. void IntrWndwSetCursorShape(int WindowID, IntrCursorShapeStruct *Cursor);
  255. void IntrWndwSetPullDownMenu(int WindowID, IntrPullDownMenuStruct *PDMenu);
  256. void IntrWndwSetRefreshFunc(int WindowID, IntrIntFunc RefreshFunc);
  257. void IntrWndwUpdatePanning(int WindowID, int x, int y);
  258. void IntrWndwSetPanning(int WindowID, int x, int y);
  259. void IntrWndwUpdateZoom(int WindowID, int Zoom);
  260. void IntrWndwSetZoom(int WindowID, int Zoom);
  261. void IntrWndwSetStatus(int WindowID, char *StatusLeft, char *StatusRight,
  262.                                 IntrBType Refresh);
  263.  
  264. /* Window drawing routines. */
  265. void IntrWndwILine(int x1, int y1, int x2, int y2);
  266. void IntrWndwRLine(IntrRType x1, IntrRType y1, IntrRType x2, IntrRType y2);
  267. void IntrWndwIMoveTo(int x, int y);
  268. void IntrWndwRMoveTo(IntrRType x, IntrRType y);
  269. void IntrWndwILineTo(int x, int y);
  270. void IntrWndwRLineTo(IntrRType x, IntrRType y);
  271. void IntrWndwIMoveRel(int x, int y);
  272. void IntrWndwRMoveRel(IntrRType x, IntrRType y);
  273. void IntrWndwILineRel(int x, int y);
  274. void IntrWndwRLineRel(IntrRType x, IntrRType y);
  275. void IntrWndwIPoly(int n, int *Points, int Fill);
  276. void IntrWndwIBar(int x1, int y1, int x2, int y2);
  277. void IntrWndwRBar(IntrRType x1,
  278.           IntrRType y1,
  279.           IntrRType x2,
  280.           IntrRType y2);
  281. void IntrWndwICircle(int x, int y, int r);
  282. void IntrWndwRCircle(IntrRType x, IntrRType y, IntrRType r);
  283. void IntrWndwIArc(int x, int y, int StAngle, int EndAngle, int r);
  284. void IntrWndwRArc(IntrRType x,
  285.           IntrRType y,
  286.           int StAngle,
  287.           int EndAngle,
  288.           IntrRType r);
  289. void IntrWndwIText(int x, int y, char *s);
  290. void IntrWndwRText(IntrRType x, IntrRType y, char *s);
  291.  
  292. /* Text handling in graphic windows. */
  293. void IntrTextInitWindow(int WindowID,
  294.             IntrBType ReadBottomLine,
  295.             IntrColorType TextColor,
  296.                         IntrColorType BottomLineColor,
  297.                         IntrScrlBarType HScrlBar,
  298.                         IntrScrlBarType VScrlBar,
  299.                         int NumOfLines,
  300.                         int LineLen);
  301. void IntrTextSetSmoothScroll(IntrBType SmoothScrolling);
  302. void IntrTextWndwRefresh(int WindowID);
  303. void IntrPrintf(int WindowID, IntrBType UpdateWindow, char *CtrlStr, ...);
  304. void IntrGetLineWindow(int WindowID, char *Buffer, int BufferLen);
  305.  
  306. /* Cursor control routines. */
  307. void IntrUseMouseDriverCursor(IntrBType UseMouseCursor);
  308. void IntrPushCursorType(void);
  309. void IntrPopCursorType(void);
  310. IntrCursorShapeStruct *IntrGetCursorType(void);
  311. void IntrSetCursorType(IntrCursorShapeStruct *Cursor);
  312. void IntrSetCursorType2(IntrCursorType CursorType,
  313.                 void (* CursorRoutine)(int, int),
  314.                 int Width, int Height, int LastX, int LastY,
  315.                 IntrBType LastHV);
  316. void IntrShowCursor(int x, int y);
  317. void IntrReposCursor(int x, int y);
  318. void IntrUnShowCursor(void);
  319.  
  320. /* Simple messages mechanism. */
  321. void IntrDrawMessage(char *Str, IntrColorType ForeColor,
  322.                             IntrColorType BackColor);
  323. void IntrEraseMessage(void);
  324.  
  325. /* Input event handling routines. */
  326. int IntrGetch(void);
  327. int IntrKbHit(void);
  328. void IntrSetIdleFunction(IntrVoidFunc IdleFunction);
  329. void IntrSetAtKeyboard(IntrBType IsATKeyboard);
  330. void IntrSetMouseSensitivity(int Sensitivity);
  331. IntrBType IntrRegisterKeyStroke(int KeyStroke, IntrIntFunc ActionFunc);
  332. void IntrSetInputDevice(int Devices);
  333. void IntrSetHandleInternalEvents(IntrBType HandleEvents,
  334.                  IntrBType PropagateEvents);
  335. void IntrInputFlush(void);
  336. IntrEventType IntrGetEventWaitSA(int *x, int *y);
  337. IntrEventType IntrGetEventWait(int *x, int *y);
  338. IntrEventType IntrGetEventNoWait(int *x, int *y);
  339. IntrEventType IntrGetTextEventWait(void);
  340. IntrEventType IntrGetTextEventNoWait(void);
  341. void IntrPushKbdEvent(int KbdEvent);
  342. IntrBType IntrMapEventToWindow(int WindowID, int x, int y, int *Wx, int *Wy);
  343. IntrBType IntrMapEventToRWindow(int WindowID, int x, int y,
  344.                           IntrRType *Wx, IntrRType *Wy);
  345.  
  346. /* Routines to control images back saving. */
  347. void IntrSetAsyncEventMode(IntrBType AsyncMode);
  348. void IntrSetSaveBackGround(IntrBType SaveBackGround);
  349. void IntrSetSaveBackMethod(IntrSaveMemType SaveBackMethod);
  350. void IntrSetSaveBackPath(char *Path);
  351.  
  352. /* Query Interaction routines. */
  353. void IntrQueryContinue(char *Question,
  354.                IntrColorType FrameColor,
  355.                IntrColorType BackColor,
  356.                IntrColorType ForeColor,
  357.                IntrColorType XorColor,
  358.                        int FrameWidth,
  359.                        IntrCursorShapeStruct *Cursor,
  360.                        int WindowID);
  361. void IntrQueryContinue2(char *Question,
  362.             void (* ExecFunc)(void),
  363.                 IntrColorType FrameColor,
  364.                 IntrColorType BackColor,
  365.                 IntrColorType ForeColor,
  366.                         int FrameWidth,
  367.                         IntrCursorShapeStruct *Cursor,
  368.                         int WindowID);
  369. IntrBType IntrQueryYesNo(char *Question,
  370.                  IntrColorType FrameColor,
  371.                  IntrColorType BackColor,
  372.                  IntrColorType ForeColor,
  373.                  IntrColorType XorColor,
  374.                          int FrameWidth,
  375.                          IntrCursorShapeStruct *Cursor,
  376.                          int WindowID);
  377. char *IntrQueryLine(char *Question,
  378.             char *Buffer,
  379.                     int BufferSize,
  380.             IntrColorType FrameColor,
  381.             IntrColorType BackColor,
  382.             IntrColorType ForeColor,
  383.                     int FrameWidth,
  384.                     int WindowID);
  385. int IntrQueryList(char *Header,
  386.           char **StrEntries,
  387.           int SizeOfEntry,
  388.                   int NumOfEntries,
  389.                   int NumOfDisplayedEntries,
  390.           IntrColorType FrameColor,
  391.           IntrColorType BackColor,
  392.           IntrColorType ForeColor,
  393.           IntrColorType XorColor,
  394.           int FrameWidth,
  395.                   IntrCursorShapeStruct *Cursor,
  396.                   int WindowID);
  397.  
  398. /* Pop Up Menu Interaction routines. */
  399. void IntrPullDownMenuDelete(IntrPullDownMenuStruct *Menu);
  400. IntrPopUpMenuStruct *IntrPopUpMenuCreate(char *Header,
  401.                      char **StrEntries,
  402.                      int SizeOfEntry,
  403.                                          int NumOfEntries,
  404.                      IntrColorType FrameColor,
  405.                          IntrColorType BackColor,
  406.                          IntrColorType ForeColor,
  407.                          IntrColorType XorColor,
  408.                              int FrameWidth,
  409.                                          IntrCursorShapeStruct *Cursor);
  410. void IntrPopUpMenuDelete(IntrPopUpMenuStruct *Menu);
  411. void IntrPopUpSetEntry(IntrPopUpMenuStruct *PUMenu, char *Entry, int Index);
  412. void IntrPopUpSetHeader(IntrPopUpMenuStruct *PUMenu, char *Header);
  413. void IntrPopUpSetFrameWidth(IntrPopUpMenuStruct *PUMenu, int FrameWidth);
  414. void IntrPopUpSetColors(IntrPopUpMenuStruct *PUMenu,
  415.                 IntrColorType FrameColor,
  416.                 IntrColorType BackColor,
  417.                 IntrColorType ForeColor,
  418.                 IntrColorType XorColor);
  419. int IntrPopUpMenu(IntrPopUpMenuStruct *PUMenu,
  420.                   int WindowID);
  421.  
  422. /* Pull Down Menu Interaction routines. */
  423. IntrPullDownMenuStruct *IntrPullDownMenuCreate(char **StrEntries,
  424.                            int SizeOfEntry,
  425.                                                int NumOfEntries,
  426.                            IntrIntFunc *ActionFuncs,
  427.                                IntrColorType FrameColor,
  428.                                IntrColorType BackColor,
  429.                                IntrColorType ForeColor,
  430.                                IntrColorType XorColor,
  431.                                    int FrameWidth);
  432. void IntrPullDownSetEntry(IntrPullDownMenuStruct *PDMenu, char *Entry,
  433.                                 int Index);
  434. void IntrPullDownSetAction(IntrPullDownMenuStruct *PDMenu,
  435.                 IntrIntFunc ActionFunc, int Index);
  436. void IntrPullDownSetFrameWidth(IntrPullDownMenuStruct *PDMenu, int FrameWidth);
  437. void IntrPullDownSetColors(IntrPullDownMenuStruct *PDMenu,
  438.                    IntrColorType FrameColor,
  439.                    IntrColorType BackColor,
  440.                    IntrColorType ForeColor,
  441.                    IntrColorType XorColor);
  442.  
  443. #endif /* INTR_LIB_H */
  444.